package cn.yy.logreportmanager.controller;

import cn.yy.logreportmanager.dto.common.ResponseBean;
import cn.yy.logreportmanager.entity.Worklog;
import cn.yy.logreportmanager.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/report-edit")
public class ReportEditController {
    @Autowired
    ReportService reportService;

    @GetMapping("/init/{empID}")
    public ResponseBean<?> init(@PathVariable("empID") String empID){
        Map<String, Object> map = new HashMap<>();
        map.put("cusMgrID",empID);
        return reportService.conditionQuery(map);
    }

    @RequestMapping(value = "/new",method = RequestMethod.POST)
    public ResponseBean<?> newReport(@RequestBody Worklog worklog){
        return reportService.newReport(worklog);
    }

    @PostMapping("/update")
    public ResponseBean<?> updateReport(@RequestBody Worklog worklog){
        return reportService.updateReport(worklog);
    }
}
